package com.ruoyi.yun.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yun.domain.YunUserRightsfunction;
import com.ruoyi.yun.service.IYunUserRightsfunctionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 权限功能管理Controller
 * 
 * @author ruoyi
 * @date 2023-10-24
 */
@RestController
@RequestMapping("/yun/rightsfunction")
public class YunUserRightsfunctionController extends BaseController
{
    @Autowired
    private IYunUserRightsfunctionService yunUserRightsfunctionService;

    /**
     * 查询权限功能管理列表
     */
    @PreAuthorize("@ss.hasPermi('yun:rightsfunction:list')")
    @GetMapping("/list")
    public TableDataInfo list(YunUserRightsfunction yunUserRightsfunction)
    {
        startPage();
        List<YunUserRightsfunction> list = yunUserRightsfunctionService.selectYunUserRightsfunctionList(yunUserRightsfunction);
        return getDataTable(list);
    }

    /**
     * 导出权限功能管理列表
     */
    @PreAuthorize("@ss.hasPermi('yun:rightsfunction:export')")
    @Log(title = "权限功能管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YunUserRightsfunction yunUserRightsfunction)
    {
        List<YunUserRightsfunction> list = yunUserRightsfunctionService.selectYunUserRightsfunctionList(yunUserRightsfunction);
        ExcelUtil<YunUserRightsfunction> util = new ExcelUtil<YunUserRightsfunction>(YunUserRightsfunction.class);
        util.exportExcel(response, list, "权限功能管理数据");
    }

    /**
     * 获取权限功能管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('yun:rightsfunction:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yunUserRightsfunctionService.selectYunUserRightsfunctionById(id));
    }

    /**
     * 新增权限功能管理
     */
    @PreAuthorize("@ss.hasPermi('yun:rightsfunction:add')")
    @Log(title = "权限功能管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YunUserRightsfunction yunUserRightsfunction)
    {
        return toAjax(yunUserRightsfunctionService.insertYunUserRightsfunction(yunUserRightsfunction));
    }

    /**
     * 修改权限功能管理
     */
    @PreAuthorize("@ss.hasPermi('yun:rightsfunction:edit')")
    @Log(title = "权限功能管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YunUserRightsfunction yunUserRightsfunction)
    {
        return toAjax(yunUserRightsfunctionService.updateYunUserRightsfunction(yunUserRightsfunction));
    }

    /**
     * 删除权限功能管理
     */
    @PreAuthorize("@ss.hasPermi('yun:rightsfunction:remove')")
    @Log(title = "权限功能管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yunUserRightsfunctionService.deleteYunUserRightsfunctionByIds(ids));
    }
}
